<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<html>
<head>
    <title>体育与健康课程管理系统</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/public/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/public/css/main.css"/>
    <link href="${pageContext.request.contextPath}/public/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <script type="text/javascript" src="${pageContext.request.contextPath}/public/js/libs/modernizr.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/public/js/jquery-3.2.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/public/js/layer/layer.js"></script>
</head>
<style>
    .scoreinp{
        width: 90px;
        height: 30px;
    }
</style>
<body>

<p style="margin-top:15px;margin-left:40px; font-size:16px; border-left:3px #006dcc solid; padding-left:5px">查看体育技能一成绩</p>
<div class="container clearfix" style="width:100%">
    <div class="main-wrap">
        <div class="search-wrap">
            <div class="search-content">
                <table class="search-tab">

                    <form method="post" action="${pageContext.request.contextPath}/examinationscoreone/newExport.action" id="formData">
                        <th width="100px" style="font-size:16px">检索:</th>
                        <td>
                            <select name="peExaminationId" style="width:120px;height:30px;border-radius:2%">
                                <option value="">全部考试</option>
                                <c:forEach items="${name }" var="x">
                                    <option value="${x.peExaminationId}">${x.peExaminationName }</option>
                                </c:forEach>
                            </select>
                        </td>
                        <td>
                            <select name="systemYearId" style="width:120px;height:30px;border-radius:2%">
                                <option value="0">${date}</option>
                                <c:forEach items="${dates }" var="z">
                                    <option value="${z.systemYearId}">${z.systemYearName}</option>
                                </c:forEach>
                            </select>
                        </td>
                        <th style="font-size:16px">成绩大于</th>
                        <td>
                            <input class="common-text" style="height:32px;width: 60px" name="peExaminationAppointmentScore" type="number"/>
                        </td>
                        <td><input type="text" class="common-text" style="height:32px" placeholder="学生学号" name="userStudentInfoNum" /></td>
                        <td><input class="btn btn-primary" onclick="getData()" value="查询" type="button"></td>
                        <td><input class="btn btn-primary" onclick="subform()" value="导出成绩" type="button"></td>
                        <td><input class="btn btn-primary" onclick="subformjwc()" value="导出成绩(教务处)" type="button"></td>
                    </form>
                    <span id="count" style="float:right;font-size: 16px;margin-right: 10%;"></span>

                </table>
            </div>
        </div>
        <div id="load" style="margin-top:80px;margin-left:40%;display: none">
        <img  src="${pageContext.request.contextPath}/public/image/loading.gif">
        </div>
        <div class="result-wrap" style="display: none">

            <div class="result-title">
            </div>
            <div class="result-content"  >
                <table class="result-tab" width="100%" id="addto">
                </table>
            </div>
        </div>

    </div>
</div>
</body>
<script>
    function subformjwc(){
        $("#formData").attr("action","${pageContext.request.contextPath}/examinationscoreone/newExportJwc.action").submit();

    }

    function subform(){
        $("#formData").attr("action","${pageContext.request.contextPath}/examinationscoreone/newExport.action").submit();

    }
    function getData(){
        $(".result-wrap").css("display","none");
        $('.result-tab').html();
        $('#count').html("");
        var peExaminationId=$("select[name=peExaminationId]").val();
        var systemYearId=$('select[name=systemYearId]').val();
        var peExaminationAppointmentScore=$('input[name=peExaminationAppointmentScore]').val();
        var userStudentInfoNum=$('input[name=userStudentInfoNum]').val();
        $("#load").css("display","block");
        $.post("${pageContext.request.contextPath}/examinationscoreone/getData.action",{peExaminationId:peExaminationId,systemYearId:systemYearId,peExaminationAppointmentScore:peExaminationAppointmentScore,userStudentInfoNum:userStudentInfoNum},function(returndata) {
            $("#load").css("display","none");
            $(".result-wrap").show();
            $('.result-tab').html("<th>学年</th><th>考试名称</th><th>学号</th><th>姓名</th><th>入学时间</th><th>所在学院</th><th>课程</th><th>课程代码</th><th>考试成绩</th><th>平时成绩</th><th>期中成绩</th><th>总成绩</th>");
            var str;
            for(var i=0;i<returndata.data.length;i++){
                var score=returndata.data[i].peExaminationAppointmentScore==null?'':returndata.data[i].peExaminationAppointmentScore;
                var normal=returndata.data[i].peExaminationNormalscore==null?'':returndata.data[i].peExaminationNormalscore;
                var mid=returndata.data[i].peExaminationMidscore==null?'':returndata.data[i].peExaminationMidscore;
                var total=returndata.data[i].peExaminationTotalscore==null?'':returndata.data[i].peExaminationTotalscore;
                var id=returndata.data[i].peExaminationAppointmentId;
                var domid="id"+id;
                str="<tr><td>"+returndata.data[i].systemYear.systemYearName+"</td><td>"+returndata.data[i].peExamination.peExaminationName+"</td><td>"+returndata.data[i].userStudentInfo.userStudentInfoNum+"</td><td>"+returndata.data[i].userStudentInfo.userStudentInfoName+"</td><td>"+returndata.data[i].userStudentInfo.userStudentInfoYear+"</td><td>"+returndata.data[i].userStudentInfo.userStudentInfoCollege+"</td><td>体育技能一考试</td><td>${code}</td><td><input class='scoreinp' value='"+score+"' onchange='updatescore(0,this.value,"+id+")'/></td><td><input class='scoreinp' value='"+normal+"' onchange='updatescore(1,this.value,"+id+")'/></td><td><input class='scoreinp' value='"+mid+"' onchange='updatescore(2,this.value,"+id+")'/> </td><td id='"+domid+"'>"+total+"</td></tr>";
                $('.result-tab').append(str);
            }
            $('#count').html("共"+(returndata.data.length)+"条记录");
        });
    }

    function updatescore(name,score,id) {
        if(name==0)
            name='peExaminationAppointmentScore';
        else if (name==1)
            name='peExaminationNormalscore';
        else
            name='peExaminationMidscore';
        layer.confirm('是否修改？', {
            btn: ['是','否'] //按钮
        }, function(){


            $.post("${pageContext.request.contextPath}/examinationscoreone/updateMultScore.action",{name:name,score:score,peExaminationAppointmentId:id},function (returndata) {
                if(returndata.code==1) {
                    $("#id"+id).text(returndata.data.Totalscore);
                    layer.msg(returndata.message, {offset: ['0px', '40%'], icon: 6, time: 1000});
                }
                else
                    layer.msg(returndata.message, { offset: ['0px', '40%'], icon:5,time:1000});
            });

        }, function(){
        });
    }
</script>
</html>
